package com.gxa.zhonglong.service.impl;

import com.gxa.zhonglong.common.ExceptionCode;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.GoodsPropertyMapper;
import com.gxa.zhonglong.pojo.GoodsProperty;
import com.gxa.zhonglong.service.GoodsPropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 宸濯
 * Date: 2021/11/01 13:07
 * Description:
 * Version: V1.0
 */
@Service
public class GoodsPropertyServiceImpl implements GoodsPropertyService {
    @Autowired
    private GoodsPropertyMapper goodsPropertyMapper;

    @Override
    public List<Map<String, Object>> selectAll() {
        return goodsPropertyMapper.selectAll();
    }

    @Override
    public void add(GoodsProperty goodsProperty) throws BusinessException {
        if (!goodsPropertyMapper.add(goodsProperty)){
            throw new BusinessException(ExceptionCode.ADD_DEFEATED);
        }
    }

    @Override
    public void update(GoodsProperty goodsProperty) throws BusinessException {

        if (!goodsPropertyMapper.update(goodsProperty)){
            throw new BusinessException(ExceptionCode.UPDATE_FALSE);
        }
    }

    @Override
    public void del(List<Long> ids) throws BusinessException {

        if (!goodsPropertyMapper.del(ids)){
            throw new BusinessException(ExceptionCode.DELETE_FALSE);
        }
    }
}
